'''
Created on Jan 30, 2012

@author: talamoig
'''

import ConfigParser

class Configurable(object):
    '''
    classdocs
    '''

    def getItem(self,item):
        try:
            return self.__configParser.get(self.__section,item)
        except ConfigParser.NoOptionError:
            return None            
        except ConfigParser.NoSectionError as e:
            print "No section %s found in file %s"%(self.__section,self.__configFile)
            raise e

    def getConfig(self):
        return self.__configParser.items(self.__section)

    def __init__(self,configFile,section=None):
        '''
        Constructor
        '''
        self.__configParser=ConfigParser.RawConfigParser()
        if not configFile:
            configFile=Configurable.defaultConfig
        if not section:
            section=self.__class__.__name__
        self.__configFile=configFile
        self.__section=section
        files=self.__configParser.read(configFile)
        if len(files)==0:
            raise ConfigParser.NoSectionError("No section %s found on file %s"%(section,configFile))

        